//
//  CGInfoCompanyFrame.m
//  SchoolClient
//
//  Created by mac on 15/12/9.
//  Copyright © 2015年 mac. All rights reserved.
//

#import "CGInfoCompanyFrame.h"

@implementation CGInfoCompanyFrame

-(void)setProduct:(CGInfoCompany *)product{
    _product = product;
    
    /** 计算CGInfoCompanyJobCell的高度 **/
    //招聘标题Frame
    CGFloat titleX = 10;
    CGFloat titleY = 10;
    CGFloat titleW = SCREEN_WIDTH - 110;
    NSMutableDictionary *titleDic = [NSMutableDictionary dictionary];
    titleDic[NSFontAttributeName] = [UIFont systemFontOfSize:16];
    CGRect titleRect = [_product.title boundingRectWithSize:CGSizeMake(titleW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:titleDic context:nil];

    titleRect.origin.x = titleX;
    titleRect.origin.y = titleY;
    _titleLabelF = titleRect;
    //NSLog(@"width:%f",titleW);
    //NSLog(@"title:%@",NSStringFromCGRect(_titleLabelF));
    
    
    //招聘单位Frame
    CGFloat companyX = titleX;
    CGFloat companyY = CGRectGetMaxY(_titleLabelF) + 10;
    CGFloat companyW = titleW;
    NSMutableDictionary *companyDic = [NSMutableDictionary dictionary];
    companyDic[NSFontAttributeName] = [UIFont systemFontOfSize:15];
    CGRect companyRect = [_product.name boundingRectWithSize:CGSizeMake(companyW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:companyDic context:nil];
    companyRect.origin.x = companyX;
    companyRect.origin.y = companyY;
    _companyLabelF = companyRect;
    
    //地点Frame
    CGFloat sizeX = titleX;
    CGFloat sizeY = CGRectGetMaxY(_companyLabelF) + 10;
    CGFloat sizeW = 35;
    CGFloat sizeH = 14;
    _sizeLabelF = CGRectMake(sizeX, sizeY, sizeW, sizeH);
    
    //工作区域Frame
    CGFloat addressX = CGRectGetMaxX(_sizeLabelF);
    CGFloat addressY = CGRectGetMaxY(_companyLabelF) + 10;
    CGFloat addressW = SCREEN_WIDTH - 55;
    CGFloat addressH = sizeH;
    _addressLabelF = CGRectMake(addressX, addressY, addressW, addressH);
    
   //Cell的高度
    _cellHeight = CGRectGetMaxY(_addressLabelF) + 10;
    
    //招聘开始时间
    CGFloat startX = SCREEN_WIDTH - 90;
    CGFloat startY = titleY;
    CGFloat startW = 80;
    CGFloat startH = 14;
    _timeStartLabelF = CGRectMake(startX, startY, startW, startH);
    
    //中间联接符
    CGFloat linkX = startX - 5;
    CGFloat linkY = startY + 20;
    CGFloat linkW = startW;
    CGFloat linkH = startH;
    _linkLabelF = CGRectMake(linkX, linkY, linkW, linkH);
    
    //招聘结束时间
    CGFloat endX = linkX + 5;
    CGFloat endY = linkY;
    CGFloat endW = startW;
    CGFloat endH = startH;
    _timeEndLabelF = CGRectMake(endX, endY, endW, endH);
    
    
}



@end
